// 角色管理相关接口
import request from '@/utils/request'
// 接口
import type { IRoleQueryData, IRoleResponseData, IRoleFormData } from './type'
import type { ResponseData } from '@/types/common'

enum API {
  ROLE_LIST_URL = '/admin/acl/role',
  ROLE_ADD_URL = '/admin/acl/role/save',
  ROLE_EDIT_URL = '/admin/acl/role/update',
  ROLE_DEL_URL = '/admin/acl/role/remove',
}

// 角色列表
export const reqRoleList = (data: IRoleQueryData) => {
  const { page, limit, roleName } = data
  const url = API.ROLE_LIST_URL + `/${page}/${limit}`
  const params = {
    roleName,
  }
  return request.get<any, IRoleResponseData>(url, { params })
}

// 新增角色
export const reqRoleAdd = (data: IRoleFormData) => {
  return request.post<any, ResponseData>(API.ROLE_ADD_URL, data)
}

// 修改角色
export const reqRoleEdit = (data: IRoleFormData) => {
  return request.post<any, ResponseData>(API.ROLE_EDIT_URL, data)
}

// 删除角色
export const reqRoleDel = (id: number) => {
  return request.delete<any, ResponseData>(API.ROLE_DEL_URL + `/${id}`)
}
